<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>项目管理管理</title>
	<meta name="decorator" content="default"/>
    <link href="${ctxStatic}/product.css" type="text/css" rel="stylesheet" />
	<link href="${ctxStatic}/font-awesome/css/font-awesome.min.css" type="text/css" rel="stylesheet" />
	<script type="text/javascript">
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }  
		function projectForm(projectId){
			var url = "${ctx}/pro/project/form?id="+projectId;
			top.$.jBox.open("iframe:"+url, "项目详情",810,$(top.document).height()-120,{
                buttons:{"提交":"ok", "关闭":true}, bottomText:"项目详情",submit:function(v, h, f){
                    var code;
                    if (v=="ok"){
                    	// 执行保存
                        //loading('正在提交，请稍等...');
                    	var flag = h.find("iframe")[0].contentWindow.submitForm();
                    	if(flag){
                    		location.reload();
                    	}
                        return false;
                    }
                }, loaded:function(h){
                    $(".jbox-content", top.document).css("overflow-y","hidden");
                }
            });
		}
		/* function ganttForm(projectId){
			var url = "${ctx}/pro/project/ganttViewData?id="+projectId;
			top.$.jBox.open("iframe:"+url, "甘特图",1180,$(top.document).height()-120,{
                buttons:{"关闭":true}, bottomText:"甘特图",submit:function(v, h, f){
                    var code;
                    if (v=="ok"){
                    	// 执行保存
                        //loading('正在提交，请稍等...');
                    	var flag = h.find("iframe")[0].contentWindow.submitForm();
                    	if(flag){
                    		location.reload();
                    	}
                        return false;
                    }
                }, loaded:function(h){
                    $(".jbox-content", top.document).css("overflow-y","hidden");
                }
            });
		} */
	</script>
</head>
<body>    
    <div class="container-fluid">
        <div id="content" class="row-fluid">
        <!-- <div id="left"></div>     
        <div id="right">  -->          
    	<ul class="nav nav-tabs">
    		<li class="active"><a id="btn" href="${ctx}/pro/project/">项目列表</a></li>
    		<shiro:hasPermission name="pro:project:create">
               <li><a href="javascript:void(0);" onclick="projectForm('');">项目添加</a></li>
            </shiro:hasPermission>
    	</ul>
    	<form:form id="searchForm" modelAttribute="project" action="${ctx}/pro/project/" method="post" class="breadcrumb form-search">
    		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
    		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
    		<ul class="ul-form">
    			<li><label>项目名称：</label>
    				<form:input path="name" htmlEscape="false" maxlength="64" class="input-medium"/>
    			</li>
    			<li><label>负责人：</label>
    				<sys:treeselect id="manager" name="manager.id" value="${project.manager.id}" labelName="manager.name" labelValue="${project.manager.name}"
    					title="用户" url="/sys/office/treeData?type=3" cssClass="input-small" allowClear="true" notAllowSelectParent="true"/>
    			</li>
    			<li><label>起始时间：</label>
    				<input name="startTime" id="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
    					value="<fmt:formatDate value="${project.startTime}" pattern="yyyy-MM-dd"/>"
    					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true,maxDate:'#F{$dp.$D(\'endTime\')}'});"/>
    			</li>
    			<li><label>结束时间：</label>
    				<input name="endTime" id="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
    					value="<fmt:formatDate value="${project.endTime}" pattern="yyyy-MM-dd"/>"
    					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true,minDate:'#F{$dp.$D(\'startTime\')}'});"/>
    			</li>
    			<li><label>项目状态：</label>
    				<form:select path="delFlag" class="input-medium">
    					<form:option value="" label=""/>
    					<form:option value="" label="全部"/>
    					<form:option value="0" label="进行中"/>
    					<form:option value="1" label="已归档"/>
    				</form:select>
    			</li>
    			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
    			<li class="clearfix"></li>
    		</ul>
    	</form:form>
    	<div class="box box-bottom">
    		<div class="product-list">
                <ul class="product-ul">
    	<sys:message content="${message}"/>
    		<c:forEach items="${page.list}" var="project">			
    			<li class="product-box">
                    <div class="product-info">
                       <div class="project-name">
                       <c:choose>
                       	<c:when test="${project.delFlag==0}">
                           <a href="${ctx}/pro/taskGroup/list?project.id=${project.id}">${project.name}</a>
                       	</c:when>
                       	<c:otherwise>
                       		${project.name}
                       	</c:otherwise>
                       </c:choose>
                       </div>
                       <div class="project-content">
                           <sapn>
                               <b>项目经理</b><br/>${project.manager.name}
                           </sapn>                                   
                           <sapn>
                               <b>截止日期</b><br/><fmt:formatDate value="${project.endTime}" pattern="yyyy-MM-dd" />
                           </sapn>
                       </div>
                       <div class="project-time">
                           <div class="box-left">
                               <span class="fa fa-calendar-o"></span> <fmt:formatDate value="${project.startTime}" pattern="yyyy-MM-dd"/>
                           </div>
                           <div class="box-right">
                               <span class="fa fa-calendar-o"></span> <fmt:formatDate value="${project.endTime}" pattern="yyyy-MM-dd"/>
                           </div>
                           <i class="fa fa-long-arrow-right" aria-hidden="true"></i>
                       </div>
                       <span class="btn-option-horizontal"> 
                            <div class="dropdown">                      
                                <span class="fa fa-ellipsis-h dropdown-toggle" data-toggle="dropdown"></span>
                                <ul class="dropdown-menu">
    							    <shiro:hasPermission name="pro:project:edit">
    							       <li>
        									<a href="javascript:void(0);" onclick="projectForm('${project.id}');">修改</a>
    								   </li>
                                       <%-- <li>
                                            <a href="${ctx}/pro/projectTask/list?project.id=${project.id}">任务管理</a>
                                       </li> --%>
                                       <c:if test="${project.delFlag==0}">
	    								   <li>
	        									<a href="${ctx}/pro/project/assign?id=${project.id}">分配人员</a>
	        								</li>
                                       </c:if>
    				                </shiro:hasPermission>
    				                <shiro:lacksRole name="project_manager">
    				                	<c:if test="${fns:getUser().id == project.manager && project.delFlag==0}">
	    								   <li>
	    									<a href="${ctx}/pro/project/delete?id=${project.id}" onclick="return confirmx('确认要归档该项目吗？', this.href)">归档</a>
	    					              </li>
    				                	</c:if>
    				                </shiro:lacksRole>
    				                <shiro:hasRole name="project_manager">
    								   <c:if test="${project.delFlag==0}">
    								   <li>
					    					<a href="${ctx}/pro/project/delete?id=${project.id}" onclick="return confirmx('确认要归档该项目吗？', this.href)">归档</a>
    					              </li>
    								   </c:if>
    				                </shiro:hasRole>
    				                <shiro:hasPermission name="pro:folder:view">
    								   <c:if test="${project.delFlag==0}">
				        				<li><a href="${ctx}/pro/folder/list?project.id=${project.id}">项目文件夹</a>
				        				</li>
    								   </c:if>
    				                </shiro:hasPermission>
    				                <shiro:hasPermission name="pro:proLog:view">
				        				<li><a href="${ctx}/pro/proLog/list?project.id=${project.id}">项目日志</a>
				        				</li>
    				                </shiro:hasPermission>
				        				<li><a href="${ctx}/pro/project/ganttViewData?id=${project.id}">项目进度</a>
				        				</li>
                                </ul>
                            </div>
                        </span>
                    </div>
                </li>
    		</c:forEach>
    			</ul>
            </div>
         </div>
    	<div class="pagination">${page}</div>
    <!-- </div> -->
    </div>
    </div>
</body>
</html>